package com.ruoyi.zhongkao.service.impl;

import java.util.List;

import com.ruoyi.gaokao.domain.GkCandidateRegistration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.zhongkao.mapper.ZkCandidateRegistrationMapper;
import com.ruoyi.zhongkao.domain.ZkCandidateRegistration;
import com.ruoyi.zhongkao.service.IZkCandidateRegistrationService;

/**
 * 中考基础信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2025-07-16
 */
@Service
public class ZkCandidateRegistrationServiceImpl implements IZkCandidateRegistrationService 
{
    @Autowired
    private ZkCandidateRegistrationMapper zkCandidateRegistrationMapper;

    /**
     * 查询中考基础信息
     * 
     * @param id 中考基础信息主键
     * @return 中考基础信息
     */
    @Override
    public ZkCandidateRegistration selectZkCandidateRegistrationById(Long id)
    {
        return zkCandidateRegistrationMapper.selectZkCandidateRegistrationById(id);
    }

    @Override
    public ZkCandidateRegistration selectZkCandidateRegistrationByIdNumber(String idNumber) {
        return zkCandidateRegistrationMapper.selectZkCandidateRegistrationByIdNumber(idNumber);
    }

    @Override
    public int upsertZkCandidateRegistration(ZkCandidateRegistration registration) {
        // 根据身份证号查询已有的记录
        ZkCandidateRegistration existing = zkCandidateRegistrationMapper.selectZkCandidateRegistrationByIdNumber(registration.getIdNumber());
        if (existing != null) {
            //更新
            registration.setId(existing.getId());
            return zkCandidateRegistrationMapper.updateZkCandidateRegistration(registration);
        }else {
            // 新增
            return zkCandidateRegistrationMapper.insertZkCandidateRegistration(registration);
        }
    }

    /**
     * 查询中考基础信息列表
     * 
     * @param zkCandidateRegistration 中考基础信息
     * @return 中考基础信息
     */
    @Override
    public List<ZkCandidateRegistration> selectZkCandidateRegistrationList(ZkCandidateRegistration zkCandidateRegistration)
    {
        return zkCandidateRegistrationMapper.selectZkCandidateRegistrationList(zkCandidateRegistration);
    }

    /**
     * 新增中考基础信息
     * 
     * @param zkCandidateRegistration 中考基础信息
     * @return 结果
     */
    @Override
    public int insertZkCandidateRegistration(ZkCandidateRegistration zkCandidateRegistration)
    {
        return zkCandidateRegistrationMapper.insertZkCandidateRegistration(zkCandidateRegistration);
    }

    /**
     * 修改中考基础信息
     * 
     * @param zkCandidateRegistration 中考基础信息
     * @return 结果
     */
    @Override
    public int updateZkCandidateRegistration(ZkCandidateRegistration zkCandidateRegistration)
    {
        return zkCandidateRegistrationMapper.updateZkCandidateRegistration(zkCandidateRegistration);
    }

    /**
     * 批量删除中考基础信息
     * 
     * @param ids 需要删除的中考基础信息主键
     * @return 结果
     */
    @Override
    public int deleteZkCandidateRegistrationByIds(Long[] ids)
    {
        return zkCandidateRegistrationMapper.deleteZkCandidateRegistrationByIds(ids);
    }

    /**
     * 删除中考基础信息信息
     * 
     * @param id 中考基础信息主键
     * @return 结果
     */
    @Override
    public int deleteZkCandidateRegistrationById(Long id)
    {
        return zkCandidateRegistrationMapper.deleteZkCandidateRegistrationById(id);
    }
}
